#ifndef MINI_ENGINE_SWAPCHAIN
#define MINI_ENGINE_SWAPCHAIN
#include <iostream>
using namespace std;
#include <vector>
#include <limits>
#include <vulkan/vulkan.hpp>
#include "WindowSurface.h"
#include "QueueFamilies.h"
#include "LogicalDevice.h"
#include "PhysicalDevice.h"
#include "InitWindow.h"

namespace mini_engine
{
    struct SwapChainSupportDetails
    {
        VkSurfaceCapabilitiesKHR capabilities;
        vector<VkSurfaceFormatKHR> formats;
        vector<VkPresentModeKHR> presentModes;
    };
    class SwapChain
    {
    private:
        SwapChain();
        static SwapChain *m_swapChain;
        SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
        VkSurfaceFormatKHR chooseSwapSurfaceFormat(const vector<VkSurfaceFormatKHR> &availableFormats);
        VkPresentModeKHR chooseSwapPresentMode(const vector<VkPresentModeKHR> &availablePresentModes);
        VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities);
        class SwapChainDestruction
        {
        public:
            ~SwapChainDestruction();
        };

    public:
        static SwapChain *getSwapChain();
        void createSwapChain(); // 创建交换链
        static VkSwapchainKHR swapChain;
        static vector<VkImage> swapChainImages;
        static VkFormat swapChainImageFormat;
        static VkExtent2D swapChainExtent;
        ~SwapChain();
    };
}

#endif